/**
 * @properties={typeid:24,uuid:"C0FB4EC7-CAE3-496A-9D42-3DEB25504F8E"}
 */
function validar() {
	controller.setSelectedIndex(1)
	if (globals.gEstadoAbm == 1)
	{
		var $sql = 'SELECT division_id FROM division WHERE codigo = ? AND empresa = ?'
		var $args = [codigo, globals.gUservID]
		var $ds = databaseManager.getDataSetByQuery('contable',$sql,$args,-1)
		if ($ds.getMaxRowIndex() != 0) 
		{		
			return [false, false, "El código ingresado ya existe"]
		}
	}
	return [true]
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"DEADAB49-B821-4D6D-850A-C48F491E345D"}
 */
function onShow(firstShow, event) {
	controller.sort("codigo asc")
}

/**
 * @properties={typeid:24,uuid:"E7A602FA-A41D-459D-A790-4B8CDE3847D5"}
 */
function imprimir()
{
	//forms.division_impresion.controller.showPrintPreview()
	jasper('impresion')
}

/**
 * @properties={typeid:24,uuid:"931CBE3A-3059-4815-82EA-1C41DEC86B38"}
 */
function pdf()
{
	//globals.metodoPdf('division_impresion','division - '+globals.glegajo,true)
	jasper('pdf')
}

/**
 * @properties={typeid:24,uuid:"A00A0AF6-8C55-41E8-ACDD-1707C7DB8ADB"}
 */
function xls()
{
	jasper('xls')
}

/**
 * @properties={typeid:24,uuid:"0CD87BF4-DE54-4301-9881-2A6B5898195B"}
 */
function csv()
{
	jasper('csv')
}

/**
 * @param {String} tipo
 * @properties={typeid:24,uuid:"C89B9441-C002-4CD8-B86C-3EE7F3DCE61B"}
 */
function jasper(tipo)
{
	var $params = {
		userv: usuarios_to_uservs.razon_social
	}
	
	globals.metodoJasper(tipo,'contable/divisiones.jasper','Divisiones',foundset,$params)
}